import request from "@/axios/axios.ts";

import type {
    AddUserInfo,
    UpdateUserInfo,
    DeleteUserInfo,
    Authentication,
    UpdatePermissions
} from './type.ts'

enum API {
    A = '/manage/add_userinfo',
    B = '/manage/modify_userinfo',
    C = '/manage/delete_userinfo',
    D = '/manage/authentication',
    E = '/manage/userinfo',
    F = '/manage/update_identity',
    xph = '/manage/token_extended'
}

// 每次打开页面时决定续签token还是注销
export const reqTokenExtended = (data: {}): Promise<any> => {
    return request.post<any, any>(API.xph, data)
}



// 添加用户
export const reqAddUser = (data: AddUserInfo): Promise<any> => {
    return request.post<any, any>(API.A, data)
}
// 修改用户
export const reqUpdateUser = (data: UpdateUserInfo): Promise<any> => {
    return request.post<any, any>(API.B, data)
}
// 删除用户
export const reqDeleteUser = (data: DeleteUserInfo): Promise<any> => {
    return request.post<any, any>(API.C, data)
}
// 登录验证
export const reqAuthentication = (data: Authentication): Promise<any> => {
    return request.post<any, any>(API.D, data)
}
// 返回用户列表
export const reqUserList = (): Promise<any> => {
    return request.post<any, any>(API.E, {})
}
// 权限修改
export const reqUpdatePermission = (data: UpdatePermissions): Promise<any> => {
    return request.post<any, any>(API.F, data)
}
